%{
// =============================================================
// IST(Index/Search Tool)
// ---------------------------------------
// Author : Woo-Hyun Kim
// Email : woorung@icu.ac.kr or woorung@nhncorp.com
// Date : Jul. 10, 2006
// =============================================================
#include <iostream>
#include <iterator>
#include <vector>
#include <list>
#include <algorithm>
#include <fstream>
#include <string>

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>

// for using tokens
#include "imap_y.h"

#ifdef __cplusplus
extern "C" {
	void trace(char *, char*);
	void ctrace(char *, char);
	int yylex(void);
}
#endif

// for checking error line
extern long yylineno;

using namespace std;
%}
NUMBER					[0-9]
ALPHABET           		[a-zA-Z]
HANGUEL					[\xB0-\xC8][\xA1-\xFE]
SPECIALSYMBOL			[`~!@#$%\^&*()\-_=+|\\{}\[\]:;"'<,>.?/]
ALPHANUMERIC			[0-9a-zA-Z_\-]
ALLCHARACTOR			[0-9a-zA-Z`~!@#$%\^&*()\-_=+|\\{}\[\]:;"'<,>.?/]
OPERATOR				[={}@\$#`]
CHARACTOR				[0-9a-zA-Z~!%\^&*()\-_+|\\\[\]:;"'<,>.?/]
CHARACTORS				[^ \t\n\r\f\v={}@\$#`]
ENTER					[\r\n]
SPACE					[ \t]
WHITESPACE				[ \t\r\n]
COMMENT					#.*\r?\n
%%
{COMMENT}				{
							yylval.strval = yytext;
							trace("[COMMENT]", yylval.strval);

							// for checking error line
							yylineno++;

							return COMMENT;
						}
"task"					{
							yylval.strval = yytext;
							trace("[TASK]", yylval.strval);
							return TASK;
						}
"action"				{
							yylval.strval = yytext;
							trace("[ACTION]", yylval.strval);
							return ACTION;
						}
"map"				{
							yylval.strval = yytext;
							trace("[MAP]", yylval.strval);
							return ACTION;
						}
"reduce"				{
							yylval.strval = yytext;
							trace("[REDUCE]", yylval.strval);
							return ACTION;
						}
"concurrent"			{
							yylval.strval = yytext;
							trace("[ACTION_TYPE]", yylval.strval);
							return CONCURRENT;
						}
"invoke"				{
							yylval.strval = yytext;
							trace("[INVOKE]", yylval.strval);
							return INVOKE;
						}
"remote"				{
							yylval.strval = yytext;
							trace("[INVOKE_TYPE]", yylval.strval);
							return REMOTE;
						}
{CHARACTORS}+			{
							yylval.strval = yytext;
							trace("[STRING]", yylval.strval);
							return STRING;
						}
{ENTER}					{	
							yytext[1] = '\0';
							yylval.symval = yytext[0];
							trace("[ENTER]", yytext);

							// for checking error line
							yylineno++;

							return ENTER;
						}
{SPACE}					{
							yytext[1] = '\0';
							yylval.symval = yytext[0];
							trace("[SPACE]", yytext);
							return SPACE;
						}
{OPERATOR}				{
							yytext[1] = '\0';
							yylval.symval = yytext[0];
							trace("[OPERATOR]", yytext);
							return yylval.symval;
						}
.						{
							yytext[1] = '\0';
							yylval.symval = yytext[0];
							trace("[ELSE]", yytext);
							return yylval.symval;
						}
%%
//--------------------------------------------------------------------
void trace(char *step, char *message)
{
#ifdef TRACE
	cout << step << message << endl;
#endif
}
//--------------------------------------------------------------------
